package com.amita.ez.base;


import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.headers.Header;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenAPIConfig {

    @Bean
    public OpenAPI qiwenFileOpenAPI() {
        return new OpenAPI()
                .components(new Components().addHeaders("Authorization",new Header().description("myHeader2 header").schema(new StringSchema())))
                .info(new Info().title("后端API")
                        .description("基于springboot + vue 框架开发的Web文件系统，旨在为用户提供一个简单、方便的文件存储方案，能够以完善的目录结构体系，对文件进行管理 。")
                        .version("v0.0.1")
                        .license(new License().name("openAPI").url("http://springdoc.org")))
                .externalDocs(new ExternalDocumentation()
//                        .description("奇文网盘gitee地址")
//                        .url("https://www.gitee.com/qiwen-cloud/qiwen-file")
                );
    }


//    @Bean
//    public OpenAPI customOpenAPI() {
//        return new OpenAPI().components(new Components().addSecuritySchemes("basicScheme",
//                new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))
//                .addParameters("myHeader1", new Parameter().in("header").schema(new StringSchema()).name("myHeader1")).addHeaders("myHeader2", new Header().description("myHeader2 header").schema(new StringSchema())))
//                .info(new Info().title("Petstore API").version("1.0").description("This is a sample server Petstore server.").termsOfService("http://swagger.io/terms/")
//                        .license(new License().name("Apache 2.0").url("http://springdoc.org")));
//    }
}
